// components/system/expert_diagnosis_result/expert_diagnosis_result.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
        diseaseList: []
    },

    /**
     * 组件的方法列表
     */
    methods: {
        reachBottomLoad() {
            console.log("诊断记录下拉触底")
        },

    },
    lifetimes: {
        async attached() {
            let userId = wx.getStorageSync('userId')
            console.log(userId)
            //未回复，未回复的放上面
            let res = await new Promise((resolve, reject) => {
                wx.request({
                    url: `http://120.77.156.205:8808/wx/disease/getUser/${userId}/0`,
                    method: 'GET',
                    success: (res) => {
                        resolve(res)
                    },
                    fail: (err) => {
                        reject(err)
                    }
                })

            })
            

            if (res.data.code == 0) {
                this.setData({
                    diseaseList: res.data.data.diseaseVoList
                })

                //已回复，已回复的放下面
                let res2 = await new Promise((resolve, reject) => {
                    wx.request({
                        url: `http://120.77.156.205:8808/wx/disease/getUser/${userId}/1`,
                        method: 'GET',
                        success: (res) => {
                            resolve(res)
                        },
                        fail: (err) => {
                            reject(err)
                        }
                    })

                })
               
                if (res2.data.code == 0) {
                    this.setData({
                        diseaseList: [...this.data.diseaseList,...res2.data.data.diseaseVoList]
                    })
                    console.log(this.data.diseaseList)
                } else {
                    wx.showToast({
                        title: '服务器异常',
                        icon: "error"
                    })
                }

            } else {
                wx.showToast({
                    title: '服务器异常',
                    icon: "error"
                })
            }

        }
    }
})
